package func;

import java.util.ArrayList;

public class BasicDoubleFuncs implements FunctionGroup<Double> {
	public String description() {
		return "basicdouble";
	}
	public ArrayList<Function<Double>> createFunctionGroup() {
		ArrayList<Function<Double>> f = new ArrayList<Function<Double>>();

		f.add(
			new Function<Double>() {
				public Double applyFunction(Double[] param) {
					return param[0] + param[1];
				}
				public String description() {
					return "d_add";
				}
				public int paramCount() {
					return 2;
				}			
		});
		
		f.add(
				new Function<Double>() {
					public Double applyFunction(Double[] param) {
						return param[0] - param[1];
					}
					public String description() {
						return "d_sub";
					}
					public int paramCount() {
						return 2;
					}			
			});
		
		f.add(
				new Function<Double>() {
					public Double applyFunction(Double[] param) {
						if(param[1] == 0)
							return Double.NaN;
						
						return param[0] / param[1];
					}
					public String description() {
						return "d_div";
					}
					public int paramCount() {
						return 2;
					}			
			});
		
		f.add(
				new Function<Double>() {
					public Double applyFunction(Double[] param) {
						return param[0] * param[1];
					}
					public String description() {
						return "d_mul";
					}
					public int paramCount() {
						return 2;
					}			
			});
		
		return f;
	}
}
